unit Ensemble2;


interface
uses
  Classes;

type
  TEnsemble2 = class
  private
    FValuesList : TStringList;
  public
    constructor Create;

    function BestByDistance : Integer;

    property ValuesList : TStringList read FValuesList write FValuesList;

  end;

implementation

uses SysUtils;

{ TEnsemble1 }

function TEnsemble2.BestByDistance: Integer;
var
  i : Integer;

  maior : Double;
begin
  Result := 0;

  maior := -99999;
  
  for i := 0 to FValuesList.Count-1 do
    begin
      if (StrToFloatDef(FValuesList.Names[i], -99999) > maior) then
        begin
          maior := StrToFloatDef(FValuesList.Names[i], -99999);
          Result := StrToIntDef(FValuesList.ValueFromIndex[i], 0);
        end;
      
    end;
end;

constructor TEnsemble2.Create;
begin
  FValuesList := TStringList.Create;
end;

end.

